Skip to content

Fix custom data auto-save issues#86

Merged
Dinopony merged 2 commits intoevilwb:mainfrom
Dinopony:tabora-save-fix
Mar 23, 2025
Merged

Fix custom data auto-save issues#86
Dinopony merged 2 commits intoevilwb:mainfrom
Dinopony:tabora-save-fix

Conversation

@Dinopony
Copy link
Collaborator

This PR fixes the auto-save issues, namely:

This was all caused by an issue in how saves are handled within the game, which is explained in detail in the issue linked above.

The solution that was picked is to move data around so that it is located in places that are coherent with how we want them saved:

  • Tabora wrench cutscene flag is now put in the unused part of Tabora platinum bolt table
  • Aranos wrench cutscene flag is now put in the unused part of Aranos platinum bolt table
  • Global platinum count is now put in the secondary inventory flag for an unused weapon
  • Global nanotech count is now put in the secondary inventory flag for an unused weapon
  • Global hypnomatic part count is now put in the secondary inventory flag for an unused weapon
  • Global bolt pack count is now put in the secondary inventory flag for an unused weapon

Moving these variables around required some modifications in Container.py for the game code to read these variables at the right address dynamically (using MIPS.get_address_halves).

For the 4 "global" variables, my first plan was to put it inside the "current ammo table" since it has 4 bytes per equipment and lots of them don't even use ammo. I did a test run with all 4 values packed into equipment 0x00 ammo, and for some reason I encountered several weird crashes I had never seen before. I suspected modifying the higher half of address has impacts, so I investigated but saw nothing that could explain it.
I tried moving those values to secondary inventory, did a test run, and everything worked perfectly fine, so I went with that solution instead.

Later, we'll need to add more custom values like those, so we'll need to dig deeper as to why the ammo count solution didn't work. Trying to put it as ammo for unused weapons or other equipement instead of equipment 0x00 might be a good start, but for now this fix is both sufficient and pretty elegant in my opinion.

@Dinopony Dinopony added the bug Something isn't working label Mar 23, 2025
@Dinopony Dinopony added this to the 0.7.0 milestone Mar 23, 2025
@Dinopony Dinopony linked an issue Mar 23, 2025 that may be closed by this pull request
Copy link
Owner

@evilwb evilwb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an elegant solution indeed. Code looks good to me. Haven't tested myself but will go ahead and approve it. I assume that you've tested the basics like that collectables are still tracked correctly.

@Dinopony
Copy link
Collaborator Author

Dinopony commented Mar 23, 2025

I did a full run with the final change, including some stress tests on saves where I loaded back auto-saves and manuel saves on purpose, and it worked as expected.

@Dinopony Dinopony merged commit e510f10 into evilwb:main Mar 23, 2025
1 check passed
@evilwb evilwb modified the milestones: 0.7.0, v0.6.3 May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tabora loading issue when returning to planet

2 participants